package net.xmat.webtest.utils;

import java.util.List;

import org.hibernate.Criteria;
import org.hibernate.Session;
import org.hibernate.criterion.Restrictions;

public class HibernateOperations {

	public static <T> List<T> list(Class<T> c, String name) {
		Session s = HibernateUtils.getSessionFactory().openSession();
		Criteria criteria = s.createCriteria(c);
		if(name != null && name.trim().length() > 0)
			criteria.add(Restrictions.ilike("name", name + "%"));
		List<T> list = criteria.list();
		s.close();
		return list;
	}
	
}
